package day2;

import java.net.Socket;
import java.util.Scanner;

import org.junit.Test;

public class IfTest {

	@Test
	public void test1() {
		System.out.println(3 > 5); // false
		System.out.println(5 <= 10);// true
	}
	
	@Test
	public void test2() {
		boolean b = false;
		System.out.println(b);
		b = !b;
		System.out.println(b);
	}
	
	@Test
	public void test3() {
		int num1 = 3;
		int num2 = 5;
		// &&短路
		System.out.println(num1 < 0 && num1++ < num2);// false
		System.out.println(num1);// 3
		System.out.println(num2);// 5
		// ||短路
		System.out.println((num1 > 0) || (num1++ < num2));// true
		System.out.println(num1);// 3
		System.out.println(num2);// 5
	}
	
//	>=90   <=100   优秀 
//	>=80    <90       良好
//	>=70    <80       一般
//	>=60    <70      及格
//	<60                    不及格
	@Test
	public void test4() {
		// 实现从控制台Console输入数据功能
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入成绩：");
		int score = scanner.nextInt();
		if (score >= 90 && score <= 100) {
			System.out.println("优秀");
		} else if (score >= 80 && score < 90 ) {
			System.out.println("良好");
		} else if (score >= 70 && score < 80) {
			System.out.println("一般");
		} else if (score >= 60 && score < 70) {
			System.out.println("及格");
		} else {
			System.out.println("不及格");
		}
	}
	
//	计算某年是不是闰年：
//	1、能被4整除，但是不能被100整除    &&
//	||
//	2、能被400整除
	@Test
	public void test6() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入年份：");
		int year = scanner.nextInt();// Alt+Shift+L
		// if (() || ()) {}
		if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
			System.out.println("是闰年");
		} else {
			System.out.println("不是闰年");
		}
	}
	
}
